package com.ease.common.models {
	import flash.events.EventDispatcher;

	import mx.utils.UIDUtil;

	public class Model extends EventDispatcher implements IModel {

		private var _listeners:Array = new Array();

		private var _uuid:String = "";

		public function Model() {
			_uuid = UIDUtil.createUID();
		}

		public function get uuid():String {
			return _uuid;
		}

		public function registerChangeListener(listener:IModelChangeListener):void {
			_listeners.push(listener);
		}

		public function removeChangeListener(listener:IModelChangeListener):void {
			_listeners.splice(_listeners.indexOf(listener),1);
		}

		public function clearChangeListener():void {
			_listeners.splice(0,_listeners.length);
		}

		public function notify():void {
			for each(var listener:IModelChangeListener in _listeners) {
				listener.notifyChanged(this);
			}
		}

	}
}